/**
 * 获取当前北京时间的完整日期和时间字符串。
 *
 * @returns {string} 格式化后的日期时间字符串，格式为 "yyyy/MM/dd HH:mm:ss"。
 *
 * @example
 * const currentTime = getTime();
 * console.log(currentTime);
 * // 输出示例: "2025/01/02 20:45:30"
 */
function getTime(date?: Date): string{
    if (!date) {
        date = new Date();
    }
    return date.toLocaleString("zh-CN", {
        timeZone: "Asia/Shanghai",
        year: "numeric",
        month: "2-digit",
        day: "2-digit",
        hour: "2-digit",
        minute: "2-digit",
        second: "2-digit",
    })
}

export default getTime;



